﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:personalplaner"
                    xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell">


    <Style x:Key="SimpleNoBorderButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border x:Name="NoBorder_HeaderCommandIntBorder" Background="Transparent" BorderBrush="Transparent" BorderThickness="1" CornerRadius="2" Margin="0" Opacity="0.6">
                        <ContentPresenter ContentSource="Content"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="NoBorder_HeaderCommandIntBorder" Property="Opacity" Value="1"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    
    
    <Style TargetType="{x:Type local:MainWindow}">
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="shell:WindowChrome.WindowChrome">
            <Setter.Value>
                <!--<shell:WindowChrome
                        ResizeBorderThickness="6"
                        CaptionHeight="40"
                        CornerRadius="6,6,6,6"
                        GlassFrameThickness="0"/>-->
                <shell:WindowChrome ResizeBorderThickness="6" CornerRadius="0" CaptionHeight="15" GlassFrameThickness="0"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:MainWindow}">
                    <AdornerDecorator>
                        <Grid >

                            <ContentPresenter Content="{TemplateBinding Content}"/>

                            <!-- Title -->
                            <Grid VerticalAlignment="Top" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(shell:WindowChrome.WindowChrome).ResizeBorderThickness}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="1" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}" FontSize="13" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Center" />
                            </Grid>

                            <!-- Buttons in the Header -->
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,0,0,0" x:Name="MainGrid">
                                <Button shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                    Command="{x:Static shell:SystemCommands.MinimizeWindowCommand}"
                                    CommandParameter="{Binding ElementName=ThisWindow}"
                                    Style="{StaticResource SimpleNoBorderButtonStyle}"
                                    Margin="3,8,2,0">
                                    <Path Data="M 0,6 L 8,6" Stroke="{TemplateBinding Foreground}" SnapsToDevicePixels="True" StrokeThickness="2" VerticalAlignment="Center"/>
                                </Button>
                                <Button shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                    Command="{x:Static shell:SystemCommands.RestoreWindowCommand}"
                                    CommandParameter="{Binding ElementName=ThisWindow}"
                                    Style="{StaticResource SimpleNoBorderButtonStyle}"
                                    Margin="3,8,2,0" x:Name="PART_RestoreButton" Visibility="Collapsed">
                                    <Grid>
                                        <Path Data="M 2,0 L 8,0 L 8,6 L 2,6 Z" Stroke="{TemplateBinding Foreground}" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                                        <Path Data="M 0,3 L 6,3 L 6,8 L 0,8 Z" Stroke="{TemplateBinding Foreground}" SnapsToDevicePixels="True" VerticalAlignment="Center" StrokeThickness="2"/>
                                    </Grid>
                                </Button>

                                <Button shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                    Command="{x:Static shell:SystemCommands.MaximizeWindowCommand}"
                                    CommandParameter="{Binding ElementName=ThisWindow}"
                                    Style="{StaticResource SimpleNoBorderButtonStyle}"
                                    Margin="3,8,2,0" x:Name="PART_MaxButton">
                                    <Path Data="M 0,0 L 8,0 L 8,7 L 0,7 Z M 0,1 L 8,1 M 0,2 L 8,2" Stroke="{TemplateBinding Foreground}" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                                </Button>
                                <Button shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                    Command="{x:Static shell:SystemCommands.CloseWindowCommand}"
                                    CommandParameter="{Binding ElementName=ThisWindow}"
                                    Style="{StaticResource SimpleNoBorderButtonStyle}"
                                    Margin="3,8,15,0">
                                    <Path Data="M 0,0 L 8,8 M 8,0 L 0,8" Stroke="{TemplateBinding Foreground}" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                                </Button>
                            </StackPanel>
                        </Grid>
                    </AdornerDecorator>
                    
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding ElementName=ThisWindow, Path=WindowState}" Value="Maximized">
                            <Setter TargetName="PART_MaxButton" Property="Visibility" Value="Collapsed"/>
                            <Setter TargetName="PART_RestoreButton" Property="Visibility" Value="Visible"/>
                            <Setter Property="BorderThickness" Value="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=WindowResizeBorderThickness}"/>
                            <Setter TargetName="MainGrid" Property="Margin" Value="0,5,0,0"/>
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>